package com.ruoyi.vote.admin.controller;

import java.util.List;
import java.util.Arrays;

import com.ruoyi.vote.admin.service.IWxUserSubService;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.vote.admin.domain.vo.WxUserSubVo;
import com.ruoyi.vote.admin.domain.bo.WxUserSubBo;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户订阅
 *
 * @author 筑巢
 * @date 2023-07-25
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/weixin/userSub")
public class WxUserSubController extends BaseController {

    private final IWxUserSubService iWxUserSubService;

    /**
     * 查询用户订阅列表
     */
    @SaCheckPermission("weixin:userSub:list")
    @GetMapping("/list")
    public TableDataInfo<WxUserSubVo> list(WxUserSubBo bo, PageQuery pageQuery) {
        return iWxUserSubService.queryPageList(bo, pageQuery);
    }

    /**
     * 删除用户订阅
     *
     * @param ids 主键串
     */
    @SaCheckPermission("weixin:userSub:remove")
    @Log(title = "用户订阅", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(iWxUserSubService.deleteWithValidByIds(Arrays.asList(ids), true));
    }
}
